<template>
    <layout>
    	<mt-header title="我的孩子">
            <a href="/member" slot="left">
                <mt-button  icon="back"></mt-button>
            </a>
		</mt-header>

		<ul>
			<li v-for="(item, index) in children">
				<div class="top_img">
					<img v-if="item.headImage=''" :src="showImage(item.headImage)"/>
				    <img v-else="" :src="showImage('/edu/img/topimg.png')">
                </div>
				<div class="top_name">
					<div>{{ item.name }}</div>
					<div>{{ item.schoolName }} {{ item.gradeName }}</div>
					<div>{{ item.detailAddress }}</div>
				</div>
				<div class="top_right iconfont" @click="setDefault(item.id)">
					<div class="office" v-show="false">
						<i class="icon-weixuanzhong"></i>
					</div>
					<div class="tab icon-xuanzhong" v-show="true">
						<i></i>
					</div>
				</div>
			</li>
		</ul>
    </layout>
</template>
<style lang="scss">
    @import "index.scss";
    .top_right .tab{
    	color: #00ffff;
    }

</style>
<script type="text/babel">
    import { api, image } from 'framework/config.js';
    import Layout from "component/layout/standard";

    import Vue from 'vue'
    import Mint from 'mint-ui';
    Vue.use(Mint);

    export default {
        components: {
            Layout
        },
        data(){
            return {
            }
        },
        computed: {
            api(){
                return api();
            }
        },
        methods: {
            showImage(url, params){
                return image(this.api.image, url, params);
            },
            setDefault(id){
                Mint.Indicator.open();
                this.$http.get('/api/children/default', {
                    params: {
                        id
                    }
                }).then((response) => {
                    Mint.Indicator.close();
                    if (response.status == 200){
                        let data = response.data;
                        if (data.code == 200) {
                            Mint.Toast('设置成功');
                        }else{
                            Mint.Toast('设置失败');
                        }
                    }else{
                        Mint.Toast('设置失败');
                    }
                });
            }
        },
        created(){
        },
        mounted() {
        }
    }
</script>

